/*******************************************************************************
*   				               DOFILE: INTERVENTION GRAPHS	                       *
********************************************************************************

    **  OUTLINE:

        - All intervention graphs

********************************************************************************/

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

  * Load dataset

use "$Intervention_dtFin/data_interventions", clear

// store all means

foreach var in parents meeting duration newparents parents_cov meeting_cov newparents_cov{
	forval i = 1/3{
		mean `var' if treatment==`i', over(round)
			eststo `var'`i'
	}
}

forval i = 2/3{
	mean completed if treatment == `i', over(round)
	eststo completed`i'
}

mean meeting if inlist(treatment,2,3), over(round)

mean meeting if inlist(treatment,2,3) & round!=1



*  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  *

	// Figure 1: Shares of parents visited in their homes by round

*  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  *

	// Share of parents

	coefplot ///
		(parents_cov1, label(T1: Information) recast(connected) ciopts(recast(rcap)) msymbol(O)) ///
		(parents_cov3, label(T3: Combined) recast(connected) ciopts(recast(rcap)) msymbol(S)) ///
		, /// twoway_options:
		scheme(s1mono) vertical nooffsets xtitle("Round") ///
		yscale(r(0 0.4))		///
		ylabel(0(.1).4)	///
		yline(0(.05).4, lc(gs12) lw(thin)) ///
		xlabel(1(1)8)	///
		sub("(a) Share of parents")	///
		legend(cols(2)) ///
    ysize(4) ///
    xsize(4) ///
		saving("$Intervention_outRaw/Figure1a.gph", replace) nodraw

	// Share of new parents

	coefplot ///
		(newparents_cov1, label(T1: Information) recast(connected) ciopts(recast(rcap)) msymbol(O)) ///
		(newparents_cov3, label(T3: Combined) recast(connected) ciopts(recast(rcap)) msymbol(S)) ///
		, /// twoway_options:
		scheme(s1mono) vertical nooffsets xtitle("Round") ///
		yscale(r(0 0.4))		///
		ylabel(0(.1).4)	///
		yline(0(.05).4, lc(gs12) lw(thin)) ///
		xlabel(1(1)8)	///
		sub("(b) Share of new parents")	///
    legend(cols(2)) ///
    ysize(4) ///
    xsize(4) ///
		saving("$Intervention_outRaw/Figure1b.gph", replace) nodraw

  // Combine graphs

	graph combine "$Intervention_outRaw/Figure1a.gph" "$Intervention_outRaw/Figure1b.gph" ///
	  , ///
    ysize(4) ///
    xsize(8) ///
    iscale(1) ///
	  scheme(s1mono) ///
		note( "Note:  Capped lines indicate the 95 percent confidence intervals.", s(medium))  ///
	  saving("$Intervention_outRaw/Figure1.gph", replace)

  graph export "$Intervention_outFin/Figure1.png", as(png) name("Graph") replace


*  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  *

	// Figure 2: Parents’ participation in meetings and meetings’ duration

*  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  *

	// Share of parents

	coefplot ///
		(meeting_cov2, label(T2: Meetings) recast(connected) ciopts(recast(rcap)) msymbol(D)) ///
		(meeting_cov3, label(T3: Combined) recast(connected) ciopts(recast(rcap)) msymbol(S)) ///
		, /// twoway_options:
		scheme(s1mono) vertical nooffsets xtitle("Round (obs. T2;T3)") /// ytitle("Share of parents") ///
		yscale(r(0 0.4))		///
		ylabel(0(.1).4)	///
		yline(0(.05).4, lc(gs12) lw(thin)) ///
		xlabel(1 "1 (31;31)" 2 "2 (31;31)" 3 "3 (31;31)" 4 "4 (31;31)" 5 "5 (30;28)" 6 "6 (30;27)" 7 "7 (25;25)" 8 "8 (18;12)", labsize(vsmall)) ///
    legend(cols(2)) ///
    ysize(4) ///
    xsize(4) ///
    sub("(a) Share of parents")	///
		saving("$Intervention_outRaw/Figure2a.gph", replace) nodraw

  // Duration in minutes

	coefplot ///
		(duration2, label(T2: Meetings) recast(connected) ciopts(recast(rcap)) msymbol(D)) ///
		(duration3, label(T3: Combined) recast(connected) ciopts(recast(rcap)) msymbol(S)) ///
		, /// twoway_options:
		scheme(s1mono) vertical nooffsets xtitle("Round") /// ytitle("Minutes") ///
		yscale(r(0 90))		///
		ylabel(0(30)90)	///
		yline(0(15)90, lc(gs12) lw(thin)) ///
		xlabel(1 "5" 2 "6" 3 "7" 4 "8") ///
   legend(cols(2)) ///
    ysize(4) ///
    xsize(4) ///
		sub("(b) Duration (in minutes)")	///
		/// note("Only records of duration available as from round 5.") ///
		nodraw ///
		saving("$Intervention_outRaw/Figure2b.gph", replace)

  // Combine graphs

	graph combine "$Intervention_outRaw/Figure2a.gph" "$Intervention_outRaw/Figure2b.gph" ///
	  , ///
	  scheme(s1mono) ///
    ysize(4) ///
    xsize(8) ///
    iscale(1) ///
		note( "Note:  Capped lines indicate the 95 percent confidence intervals.", s(medium))  ///
    saving("$Intervention_outRaw/Figure2.gph", replace)

  graph export "$Intervention_outFin/Figure2.png", as(png) name("Graph") replace

*  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  *

	// Figure 3: Topics discussed in meetings (percentage of schools)

*  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  *


local contribution_name "(d) Collecting contributions"
local accountability_name "(a) School accountability"
local parcom_name "(c) Parents' committee"
local acom_name "(b) Parental involvement"

foreach var in contribution accountability parcom acom{
	mean `var' if treatment==2, over(round)
	eststo `var'_2
	mean `var' if treatment==3, over(round)
	eststo `var'_3

coefplot ///
	(`var'_2 ///
		, label(T2: Meetings) recast(connected) ciopts(recast(rcap)) msymbol(D)) ///
	(`var'_3 ///
		, label(T3: Combined) recast(connected) ciopts(recast(rcap)) msymbol(S)) ///
	, scheme(s1mono) vertical nooffsets xtitle("Round (obs. T2;T3)") /// ytitle("Share of schools") ///
	yscale(r(0 1))		///
	ylabel(0(.2)1)	///
	yline(0(.2)1, lc(gs12) lw(thin)) ///
	xlabel(1 "1 (31;31)" 2 "2 (31;31)" 3 "3 (31;31)" 4 "4 (31;31)" 5 "5 (30;28)" 6 "6 (30;27)" 7 "7 (25;25)" 8 "8 (18;12)", labsize(small)) ///
  legend(cols(2)) ///
  ysize(3.5) ///
  xsize(4) ///
	sub("``var'_name'", span)	///
	saving("$Intervention_outRaw/Figure3_`var'.gph", replace) nodraw

}

graph combine "$Intervention_outRaw/Figure3_accountability.gph" ///
							"$Intervention_outRaw/Figure3_acom.gph" ///
							"$Intervention_outRaw/Figure3_parcom.gph" ///
							"$Intervention_outRaw/Figure3_contribution.gph" ///
, ///
rows(2) cols(2) ///
ysize(8) ///
xsize(8) ///
iscale(.45) ///
scheme(s1mono) ///
note("Note:  Capped lines indicate the 95 percent confidence intervals.", s(vsmall))  ///
saving("$Intervention_outRaw/Figure3.gph", replace)

graph export "$Intervention_outFin/Figure3.png", as(png) name("Graph") replace

*  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  *

	// Figure 4: Facility related topics discussed in meetings (percentage of schools)

*  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  *

local higiene_name "(a) Hygiene related improvement"
local safety_name "(b) Safety related improvements"

foreach var in higiene safety general_improvements{
	mean `var' if treatment==2, over(round)
	eststo `var'_2
	mean `var' if treatment==3, over(round)
	eststo `var'_3

coefplot ///
	(`var'_2 ///
		, label(T2: Meetings) recast(connected) ciopts(recast(rcap)) msymbol(D)) ///
	(`var'_3 ///
		, label(T3: Combined) recast(connected) ciopts(recast(rcap)) msymbol(S)) ///
	, scheme(s1mono) vertical nooffsets xtitle("Round (obs. T2;T3)") /// ytitle("Share of schools") ///
	yscale(r(0 .8))		///
	ylabel(0(.2).8)	///
	yline(0(.1).8, lc(gs12) lw(thin)) ///
	xlabel(1 "1 (31;31)" 2 "2 (31;31)" 3 "3 (31;31)" 4 "4 (31;31)" 5 "5 (30;28)" 6 "6 (30;27)" 7 "7 (25;25)" 8 "8 (18;12)", labsize(vsmall)) ///
  legend(cols(2)) ///
  ysize(4) ///
  xsize(4) ///
	sub("``var'_name'", span)	///
	nodraw ///
	saving("$Intervention_outRaw/Figure4_`var'.gph", replace)

}

graph combine "$Intervention_outRaw/Figure4_higiene.gph" "$Intervention_outRaw/Figure4_safety.gph" ///
, ///
scheme(s1mono) ///
ysize(4) ///
xsize(8) ///
iscale(1) ///
note( "Note:  Capped lines indicate the 95 percent confidence intervals.", s(medium))  ///
saving("$Intervention_outRaw/Figure4.gph", replace)

graph export "$Intervention_outFin/Figure4.png", as(png) name("Graph") replace


********************************************************************************






*
